Resource (computer science)

A resource, or system resource, is any physical or virtual component of limited availability within a computer system. Every device connected to a computer system is a resource. Every internal system component is a resource. Virtual system resources include files, network connections and memory areas.

Major resource types

Resource management

A resource handle is an identifier for a resource that is currently being accessed. Resource handles can be opaque, in which case they are often integer numbers, or they can be pointers that allow access to further information. Common resource handles are file descriptors and sockets.

A situation when a computer program allocates a resource and fails to deallocate it after use is called a resource leak. Resource tracking is the ability of an operating system, virtual machine or other program to terminate the access to a resource that has been allocated but not deallocated after use. When implemented by a virtual machine this is often done in the form of garbage collection. Without resource tracking programmers must take care of proper manual resource deallocation. They may also use the RAII technique to automate this task.

Access to memory areas is often controlled by semaphores, which allows a pathological situation called a deadlock, when different threads or processes try to allocate resources already allocated by each other. A deadlock usually leads to a program becoming partially or completely unresponsive.

Access to resources is also sometimes regulated by queuing; in the case of computing time on a CPU the controlling algorithm of the task queue is called a scheduler.

See also